<template>
	<view lass="safe-area-inset-bottom">
				<!-- 搜索框 -->
				<view class="swip_header">
				<view class="slot-box">
					<view style="width: 100%;">
						<uni-search-bar v-model="queryParams.name" type="text" @confirm="handleQuery" @input="handleQuery" placeholder="请输入模板名称" />
					</view>
				</view>
				</view>
				
			<view class="listTop" v-if="templateList.length !== 0">
				<view v-for="(item, index) in templateList" :key="index">
						<view class="add-find-box card-border" style="margin:20rpx;">
							<view class="flex_between">
								<p class="grid-hidden" style="width: 70%;">模板名称：{{ item.name }}</p>
								<button size="mini" class="green_btn" @click="useChange(item)">使用</button>
							</view>
						<p class="grid-integral">合同类型：{{ item.contractTypeName }}</p>
						<p class="grid-integral">业务分类：{{ item.contractBusinessTypeName }}</p>
						<p class="grid-integral">签署参与方：{{ item.signMax }}</p>
						<p class="grid-integral">签署要求：
						   <span v-if="item.signSet == 0"><uni-tag text="企业盖章" type="success" /></span>
			               <span v-if="item.signSet == 1"><uni-tag text="企业盖章+授权人盖章" type="success" /></span></p>
					</view>			
				</view>
			</view>

			<!-- 暂无数据 -->
			<luanqingEmpty :show="true" text="没有更多数据啦" v-else />
	</view>
</template>

<script>
	import {listTemplate, selectAvailableTemplates} from "@/api/ec/console/busiConfig/template";
	import luanqingEmpty from '@/components/luanqing-empty/luanqing-empty';
	export default {
		components: {
			luanqingEmpty
		},
		name: "selectTemplate",
		data() {
			return {
				tables: null, // 选中数组值
				templateList: [],
				// 查询参数
				queryParams: {
				  pageNum: 1,
				  pageSize: 10,
				  companyId: null,
				  staffId: null,
				  name: null,
				  status: null,
				  contractNumber: null,
				},      
			};
		},
		onLoad(option) {
			this.getList()
		},
		methods: {
			/** 查询企业信息列表 */
			getList() {
        this.$modal.loading();
			    listTemplate(this.queryParams).then(response => {
					uni.hideLoading()
			      this.templateList = response.rows;
			    });
			},    
			/** 搜索 */
			handleQuery() {
				this.getList()
			},
			/** 使用模板 */
			useChange(row){
				this.tables = row;
				this.handleImportTable(row);
			},
		    handleImportTable(value) {
		      if(this.tables==0 || this.tables==null){
		        this.$modal.msgError("请选择模板");
		        return;
		      }
				uni.$emit("templateList",this.tables)
				uni.navigateBack(1)
		    },	
			
		}
	}
</script>
